32. Exercise: Add Resource Qualifiers
Add Resource Qualifiers
You're on the very last step for Sunshine and completing this course!!
You've learned how to create unique layout resources for screens of different sizes and orientations. In this exercise, you'll create a unique layout that displays when a device is in landscape orientation.
Use the qualifier -land to create this layout and modify the layout so that it is a horizontal linear layout that contains the today list item and general list items side by side.
Dimensions
You'll also want to create dimensions that are unique to this landscape layout and tablet layouts that help consistently space out the views.
Create the version of dimens that will be used in landscape mode as follows:
| Dimension Name | Value |
|---|---|
| forecast_detail_horizontal_padding | 16dp |
| forecast_detail_vertical_padding | 44dp |
AND create the version of dimens that will be used when the smallest width of the screen is 600dp as follows:
| Dimension Name | Value |
|---|---|
| forecast_detail_vertical_padding | 24dp |
| today_forecast_list_item_vertical_padding | 24dp |
| list_item_icon_margin_right | 24dp |
| list_item_icon_margin_end | @dimen/list_item_icon_margin_right |
| list_item_padding_horizontal | 24dp |
Exercise Code
Exercise: S12.04-Exercise-ResourceQualifiers
Add Resource Qualifiers
SOLUTION:
- In a new landscape values folder, create the version of dimens that will be used in landscape mode
- In another new values folder for tablet, create the version of dimens that will be used when the smallest width of the screen is 600dp
- Add a new folder for landscape layouts and create the version of activity_detail that will be used in landscape mode